/* Reset and base styles optimized for iframe and mobile-first design */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    overflow: hidden;
    touch-action: manipulation;
}

/* Main container with responsive height handling */
.game-container {
    width: 100%;
    height: 100vh; /* Default for standalone */
    height: 450px; /* Override for iframe */
    display: flex;
    flex-direction: column;
    position: relative;
    background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

/* Media query for standalone browser tab */
@media (min-height: 500px) {
    .game-container {
        height: 90vh;
    }
}

/* Progress tracking section */
.progress-container {
    background: rgba(255,255,255,0.9);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 10;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    width: 0%;
    transition: width 0.5s ease-in-out;
    border-radius: 4px;
}

.step-indicator {
    font-size: 12px;
    font-weight: bold;
    color: #2e7d32;
    white-space: nowrap;
}

/* Scene area for characters and interactions */
.scene-container {
    flex: 1;
    position: relative;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><rect fill="%23f0f8f0" width="100" height="100"/><circle cx="20" cy="20" r="2" fill="%23c8e6c9"/><circle cx="80" cy="30" r="1.5" fill="%23c8e6c9"/><circle cx="60" cy="70" r="2.5" fill="%23c8e6c9"/></svg>') repeat;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 16px;
    min-height: 120px;
}

/* Character styling with interaction states */
.character {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 8px;
    border-radius: 12px;
    background: rgba(255,255,255,0.8);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    min-width: 60px;
    touch-action: manipulation;
}

.character:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
    background: rgba(255,255,255,0.95);
}

.character.selected {
    background: #e8f5e8;
    border: 2px solid #4caf50;
    transform: scale(1.05);
}

.character-sprite {
    font-size: 32px;
    margin-bottom: 4px;
    transition: transform 0.2s ease;
}

.character:hover .character-sprite {
    transform: scale(1.1);
}

.character-name {
    font-size: 11px;
    font-weight: bold;
    color: #2e7d32;
    text-align: center;
}

/* Dialogue system */
.dialogue-container {
    background: rgba(255,255,255,0.95);
    padding: 12px 16px;
    border-top: 2px solid #e0e0e0;
    min-height: 60px;
    display: flex;
    align-items: center;
}

.dialogue-box {
    width: 100%;
    position: relative;
}

.dialogue-text {
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    text-align: center;
    animation: typewriter 0.5s ease-in-out;
}

@keyframes typewriter {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Decision buttons with mobile-optimized sizing */
.decision-container {
    padding: 12px 16px;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    border-top: 1px solid #e0e0e0;
}

.decision-btn {
    background: linear-gradient(135deg, #4caf50, #66bb6a);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(76,175,80,0.3);
    min-height: 44px; /* Touch-friendly minimum */
    flex: 1;
    min-width: 120px;
    max-width: 200px;
    touch-action: manipulation;
}

.decision-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76,175,80,0.4);
    background: linear-gradient(135deg, #66bb6a, #4caf50);
}

.decision-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(76,175,80,0.3);
}

.decision-btn.wrong {
    background: linear-gradient(135deg, #f44336, #ef5350);
    box-shadow: 0 2px 8px rgba(244,67,54,0.3);
}

.decision-btn.start-btn {
    background: linear-gradient(135deg, #2196f3, #42a5f5);
    font-size: 14px;
    padding: 16px 24px;
}

/* Feedback system for consequences */
.feedback-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 20;
    animation: feedbackSlide 0.5s ease-out;
}

.feedback-box {
    background: rgba(255,255,255,0.98);
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    text-align: center;
    max-width: 280px;
    border: 3px solid #4caf50;
}

.feedback-box.negative {
    border-color: #f44336;
}

.feedback-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.feedback-text {
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    font-weight: bold;
}

@keyframes feedbackSlide {
    from { 
        opacity: 0; 
        transform: translate(-50%, -50%) scale(0.8); 
    }
    to { 
        opacity: 1; 
        transform: translate(-50%, -50%) scale(1); 
    }
}

/* Celebration overlay for achievements */
.celebration-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(76,175,80,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    animation: celebrationAppear 0.6s ease-out;
}

.celebration-content {
    text-align: center;
    color: white;
    padding: 24px;
}

.celebration-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: bounce 1s infinite;
}

.celebration-text {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 12px;
}

.celebration-message {
    font-size: 16px;
    margin-bottom: 20px;
    line-height: 1.4;
}

.celebration-btn {
    background: white;
    color: #4caf50;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
}

.celebration-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

@keyframes celebrationAppear {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* Tooltip system for additional information */
.tooltip {
    position: absolute;
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 40;
    pointer-events: none;
    max-width: 200px;
    text-align: center;
    line-height: 1.3;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0,0,0,0.9);
}

/* Utility classes */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .character-sprite {
        font-size: 28px;
    }
    
    .character-name {
        font-size: 10px;
    }
    
    .dialogue-text {
        font-size: 13px;
    }
    
    .decision-btn {
        font-size: 12px;
        padding: 10px 16px;
        min-width: 100px;
    }
    
    .feedback-box {
        max-width: 240px;
        padding: 16px;
    }
    
    .celebration-icon {
        font-size: 48px;
    }
    
    .celebration-text {
        font-size: 20px;
    }
}